<template>
    <div>
        <keep-alive>
            <router-view v-if="$route.meta.keepAlive" />
        </keep-alive>
        <router-view v-if="!$route.meta.keepAlive" />
    </div>

</template>

<script>
import { mapGetters } from 'vuex';
export default {
    name: "nested",
    beforeRouteLeave (to, from, next) {
    // 清除缓存数据的逻辑
    if(!this.tagView.some(item=>item.name==from.name)){
        this.$destroy(); // 销毁当前组件实例
    }
   
    next(); // 必须调用next()来结束路由守卫流程
  },computed:{
    ...mapGetters(['tagView'])
  }

};
</script>

<style></style>